Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Bublé is a JavaScript compiler that takes your ES2015+ code and turns it into code that can run in older browsers. It is designed to be fast and to produce compact output.
Transpiling ES6 to ES5
Bublé can transpile modern ES6+ syntax to ES5, making it compatible with older browsers. This example shows how an arrow function is transformed into a regular function.
const buble = require('buble');
const result = buble.transform(`const add = (a, b) => a + b;`);
console.log(result.code); // 'var add = function (a, b) { return a + b; };'
Source Maps
Bublé can generate source maps, which are useful for debugging. This example shows how to generate a source map for the transformed code.
const buble = require('buble');
const result = buble.transform(`const add = (a, b) => a + b;`, { source: 'input.js', file: 'output.js' });
console.log(result.map);
Custom Transforms
Bublé allows you to customize which transformations to apply. This example shows how to disable the transformation of ES6 classes.
const buble = require('buble');
const result = buble.transform(`class Person { constructor(name) { this.name = name; } }`, { transforms: { classes: false } });
console.log(result.code);
Babel is a widely-used JavaScript compiler that supports a wide range of plugins and presets for transforming ES6+ code to ES5. It is more feature-rich and extensible compared to Bublé, but it can be slower and produce larger output.
TypeScript is a superset of JavaScript that adds static types. It also includes a compiler that can transpile TypeScript (and modern JavaScript) to ES5. While it offers more features like type checking, it is more complex to set up and use compared to Bublé.
esbuild is an extremely fast JavaScript bundler and minifier. It can also transpile modern JavaScript to older versions. It is known for its speed and efficiency, but it is less configurable than Babel.
The blazing fast, batteries-included ES2015 compiler. Try it out at buble.surge.sh
Yes – insofar as it's a tool that can transform ES2015 into JavaScript that will run today. The key differences:
Unlike Babel, 100% spec compliance isn't an over-riding goal – for example it won't add runtime checks to ensure that you're not instantiating classes without new
. (Complete spec compliance is impossible anyway, as some ES2015 features can't be transpiled.) You'll also need to bring your own polyfill (e.g. es6-shim). You have been warned!
Via the command line...
npm install -g buble
buble input.js > output.js
...or via the JavaScript API:
var buble = require( 'buble' );
var result = buble.transform( source ); // { code: ..., map: ... }
Currently:
let
and const
)Bublé only transpiles language features – it doesn't attempt to shim or polyfill the environment. If you want to use things like array.findIndex(...)
or 'x'.repeat(3)
you'll have to bring your own polyfill.
It also refuses to transpile things that result in ES5 code with size or performance hazards (subject to change! It might support some of these features in future), or which are altogether impossible to transpile to ES5.
Map
, Set
, WeakMap
, WeakSet
, Proxy
, Symbol
class
keyword correctly – it doesn't stop you from instantiating a class without new
, for example, and doesn't quite adhere to the spec as regards enumerability of methods, etc. Think of Babel's 'loose' mode, except looser.Hell no. Still to come:
babel-node
and babel-register
Please send in your bug reports and pull requests.
I love Babel: it's an amazing project that has changed how the world writes JavaScript, and I'm in awe of the people who created and maintain it. But it adds overhead and configuration complexity, and so it's not the right tool for every project. Personally, I became frustrated at how much longer my builds took when Babel got involved, and the amount of time it would take to set it up with new projects.
Bublé is an ES2015 compiler that I built to serve my needs and opinions – a no-frills, easy-to-use tool that handles the subset of ES2015 that I actually use (which excludes for...of
, generators, and other things that don't transpile well). It doesn't attempt to boil the ocean. If you share my needs and opinions, you will prefer Bublé; if you don't, you should continue to use Babel, which is more complete, more mature, and better supported.
MIT
FAQs
The blazing fast, batteries-included ES2015 compiler
The npm package buble receives a total of 138,155 weekly downloads. As such, buble popularity was classified as popular.
We found that buble demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.